package com.skt.domain.VO;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 租赁订单的视图对象（View Object）
 * 用于向前端返回订单信息，不暴露数据库实体（PO），提高安全性与灵活性。
 */
@Data
@Schema(description = "租赁订单详情 VO")
public class RentalOrderVO {

    @Schema(description = "订单主键 ID", example = "1001")
    private Long id;

    @Schema(description = "订单编号，全局唯一", example = "R202511271030123456")
    private String orderNo;

    @Schema(description = "租赁开始日期（不含时间）", example = "2025-12-01")
    private LocalDate startDate;

    @Schema(description = "租赁结束日期（不含时间）", example = "2025-12-05")
    private LocalDate endDate;

    @Schema(description = "用户备注信息", example = "请尽快发货，急用")
    private String remark;

    @Schema(description = "租赁总天数（含首尾日）", example = "5")
    private Integer totalDays;

    @Schema(description = "订单总金额（租金合计，单位：元）", example = "299.00")
    private BigDecimal totalAmount;

    @Schema(description = "订单状态码：1-待支付，2-已支付，3-已发货，4-已取货，5-已归还，6-已取消", example = "2")
    private Integer status;

    @Schema(description = "订单状态中文描述", example = "已支付")
    private String statusDesc;

    @Schema(description = "订单创建时间（ISO 8601 格式）", example = "2025-11-27T10:30:00")
    private LocalDateTime createdAt;

    @Schema(description = "订单包含的服装明细列表")
    private List<OrderItemVO> items;

    /**
     * 订单明细的嵌套 VO 类
     * 描述订单中某一件服装的具体信息
     */
    @Data
    @Schema(description = "订单中的服装明细项")
    public static class OrderItemVO {

        @Schema(description = "服装 ID", example = "2001")
        private Long costumeId;

        @Schema(description = "服装名称", example = "唐制齐胸襦裙")
        private String costumeName;

        @Schema(description = "租赁数量", example = "2")
        private Integer quantity;

        @Schema(description = "日租金（单位：元）", example = "59.90")
        private BigDecimal dailyPrice;

        @Schema(description = "该服装在本订单中的小计金额（= 日租金 × 数量 × 总天数）", example = "599.00")
        private BigDecimal subtotal;
    }
}